#ifndef ADDFRIENDDIALOG_H
#define ADDFRIENDDIALOG_H

#include <QDialog>
#include <QWidget>
#include <QIcon>
#include <QLabel>
#include <QPushButton>
#include <QVBoxLayout>
#include <QLineEdit>
#include <QScrollArea>
#include <QScrollBar>
#include <QStyleOption>
#include <QPainter>

#include "Debug.h"
#include "model/data.h"
#include "model/datacenter.h"

using model::UserInfo;

///
///  搜索好友结果item
///

class FriendResultItem :public QWidget {
    Q_OBJECT
public:
    FriendResultItem(const UserInfo& userInfo, QWidget* parent = nullptr);

    void paintEvent(QPaintEvent *) override; // 自定义类的样式需要重写此函数才能生效

private:
    // 存储该好友的信息
    const UserInfo& m_userInfo;
    QPushButton* m_addBtn = nullptr;
};

///
///  搜索界面类
///
class AddFriendDialog : public QDialog
{
    Q_OBJECT
public:
    AddFriendDialog(QWidget* parent = nullptr);

    void addResult(const UserInfo& userInfo);

    void clear();

    QLineEdit* getLineEdit() { return m_searchEdit; }

public slots:
    void clickAddBtn();
    void clickSearchBtnDone();

private:
    QWidget* m_resultContainer = nullptr;  // 网格布局容器
    QLineEdit* m_searchEdit = nullptr;     //
};

#endif // ADDFRIENDDIALOG_H
